import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/miniProgram/miniProgramSeatConfig/mini_program_seat_config_page.dart';
import 'package:boss/ui/page/miniProgram/miniProgramTableConfig/mini_program_table_config_page.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:boss/ui/widget/image/base_image.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:boss/ui/widget/title_row_button.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:router/annotation.dart';

@RouterConfig(MiniProgramConfigPage.pageName)
class MiniProgramConfigPage extends StatefulWidget {
  static const pageName = '/MiniProgramConfigPage';

  @override
  _MiniProgramConfigPageState createState() => _MiniProgramConfigPageState();
}

class _MiniProgramConfigPageState extends BaseState<MiniProgramConfigPage> {
  _MiniProgramConfigPageState() : super(MiniProgramConfigPage.pageName);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CenterTitleAppBar(title: '开通扫码点餐'),
      body: SingleChildScrollView(
          padding: EdgeInsets.symmetric(horizontal: 30.w),
          child: Column(
            children: [
              buildHeader(),
              buildRow(
                icon: 'assets/image/miniProgram/mpc1.png',
                title: '自动生成专属点餐二维码',
                onTap: nextPage,
              ),
              buildRow(
                icon: 'assets/image/miniProgram/mpc2.png',
                title: '绑定随箱赠送的点餐二维码',
                onTap: nextPage,
              ),
            ],
          )),
    );
  }

  Widget buildHeader() {
    return Container(
      height: 120.w,
      alignment: Alignment.centerLeft,
      child: Text('生成/绑定座位号点餐二维码：', style: TextStyleConstant().normal_1_32),
    );
  }

  Widget buildRow({String icon, String title, VoidCallback onTap}) {
    return GestureDetector(
      child: ShadowRadiusCard(
        height: 180.w,
        padding: EdgeInsets.symmetric(horizontal: 20.w),
        child: TitleRowButton(
          title: Row(
            children: [
              BaseImage(
                icon,
                width: 120.w,
                height: 120.w,
              ),
              Container(
                margin: EdgeInsets.only(left: 20.w),
                child: Text(
                  title,
                  style: TextStyleConstant().normal_1_28,
                ),
              ),
            ],
          ),
          hintText: '',
        ),
        margin: EdgeInsets.only(bottom: 30.w),
      ),
      onTap: onTap,
    );
  }

  void nextPage() {
    Navigator.pushNamed(context, MiniProgramTableConfigPage.pageName);
  }
}
